<%-
require 'builder'
response.headers["Content-Type"] = "application/xml; charset=utf-8"

xml = Builder::XmlMarkup.new(:indent => 1)

xml.instruct!
xml.rss "version" => "2.0" do
  xml.channel do
    xml.title "Outbox"
    xml.lastBuildDate @at_messages.last.timestamp.rfc822
      @at_messages.each do |msg|
        xml.item do
          # Show body in title if subject is empty
          if msg.subject.blank?
            xml.title msg.body
          else
            xml.title msg.subject
            xml.description msg.body
          end

          xml.author msg.from
          xml.to msg.to
          xml.guid msg.guid
          xml.pubDate msg.timestamp.rfc822
        end
      end
   end
end
-%><%= xml.target!.html_safe -%>
